﻿
Public Class bytesByte
    Inherits bytesbase(Of Byte)

    Public Overrides Sub frombytes(ByVal b As bytes)
        convertor.tobyte(b, d)
    End Sub

    Public Overrides Function tobytes() As bytes
        Dim rtn As bytes = Nothing
        convertor.tobytes(d, rtn)

        Return rtn
    End Function

    Public Sub New()
        MyBase.New()
    End Sub

    Public Sub New(ByVal i As Byte)
        MyBase.New(i)
    End Sub

    Public Overloads Shared Widening Operator CType(ByVal this As Byte) As bytesByte
        Return New bytesByte(this)
    End Operator
End Class

Public Class bytesInt16
    Inherits bytesbase(Of Int16)

    Public Overrides Sub frombytes(ByVal b As bytes)
        convertor.toint16(b, d)
    End Sub

    Public Overrides Function tobytes() As bytes
        Dim rtn As bytes = Nothing
        convertor.tobytes(d, rtn)

        Return rtn
    End Function

    Public Sub New()
        MyBase.New()
    End Sub

    Public Sub New(ByVal i As Int16)
        MyBase.New(i)
    End Sub

    Public Overloads Shared Widening Operator CType(ByVal this As Int16) As bytesInt16
        Return New bytesInt16(this)
    End Operator
End Class

Public Class bytesInt32
    Inherits bytesbase(Of Int32)

    Public Overrides Sub frombytes(ByVal b As bytes)
        convertor.toint32(b, d)
    End Sub

    Public Overrides Function tobytes() As bytes
        Dim rtn As bytes = Nothing
        convertor.tobytes(d, rtn)

        Return rtn
    End Function

    Public Sub New()
        MyBase.New()
    End Sub

    Public Sub New(ByVal i As Int32)
        MyBase.New(i)
    End Sub

    Public Overloads Shared Widening Operator CType(ByVal this As Int32) As bytesInt32
        Return New bytesInt32(this)
    End Operator
End Class

Public Class bytesInt64
    Inherits bytesbase(Of Int64)

    Public Overrides Sub frombytes(ByVal b As bytes)
        convertor.toint64(b, d)
    End Sub

    Public Overrides Function tobytes() As bytes
        Dim rtn As bytes = Nothing
        convertor.tobytes(d, rtn)

        Return rtn
    End Function

    Public Sub New()
        MyBase.New()
    End Sub

    Public Sub New(ByVal i As Int64)
        MyBase.New(i)
    End Sub

    Public Overloads Shared Widening Operator CType(ByVal this As Int64) As bytesInt64
        Return New bytesInt64(this)
    End Operator
End Class
